﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bootstrap.MVC.Common;
using Bootstrap.MVC.Utils;

namespace Bootstrap.MVC.Widgets
{
    public class ButtonDropDownBuilder : WidgetBuilderBase<IButtonDropDownModel, 
                                           ButtonDropDownBuilder, 
                                           ButtonDropDownHtmlGenerator,
                                           ButtonDropDownScriptGenerator>
    {
        public ButtonDropDownBuilder( IButtonDropDownModel model,
                             ButtonDropDownHtmlGenerator htmlGenerator,
                             ButtonDropDownScriptGenerator scriptGenerator )
            : base(model, htmlGenerator, scriptGenerator) { }


        public ButtonDropDownBuilder(IButtonDropDownModel model) : base(model) { }


        #region Public Methods
        public ButtonDropDownBuilder Split(bool split=true)
        {
            Model.Split = split;
            return this;
        }

        public ButtonDropDownBuilder DropUp(bool dropup = true)
        {
            Model.DropUp = dropup;
            return this;
        }


        //TODO- must be moved to base
        public ButtonDropDownBuilder Size(ButtonSize size)
        {
            Guard.IsNotNull(size, "size");
            Model.Size = size;
            return this;
        }

        //TODO- must be moved to base
        public ButtonDropDownBuilder Skin(Skins skin)
        {
            Model.Skin = skin;
            return this;
        }
        
        //public ButtonBuilder Block(bool block= true)
        //{
        //    Model.Block = block;
        //    return this;
        //}


        //public ButtonBuilder Icon(string icon,IconColors color = IconColors.Black, LeftOrRight position = LeftOrRight.Left)
        //{
        //    Guard.IsNotNullOrEmpty(icon, "icon");

        //    Model.Icon = icon;
        //    Model.IconColor = color;
        //    Model.IconPosition = position;
        //    return this;
        //}


        public ButtonDropDownBuilder Items(Action<DropDownItemFactory> itemAction)
        {
            Guard.IsNotNull(itemAction, "itemAction");

            var eventFactory = new DropDownItemFactory(Model.Menu);
            itemAction(eventFactory);

            return this;
        }

        public ButtonDropDownBuilder Bind(IEnumerable<IDropDownItemModel> items)
        {
            Guard.IsNotNull(items, "items");

            var menu = new DropDownMenuModel(items);
            Model.Menu = menu;
            return this;
        }

        #endregion Public Methods


    }
}
